package service

import (
	"Graphite/database"
	"Graphite/model"
	"context"
	"go.mongodb.org/mongo-driver/bson"
	"log"
)

//配置
func ResultCon(id interface{}, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var one model.PeiZhi
	err := collection.FindOne(context.Background(), bson.M{"_id": id}).Decode(&one)
	if err != nil {
		log.Println(err)
	}
	return one
}

//浸渍1
//添加浸渍小时数据
func ResultHour(id interface{}, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var one model.DippingHourData
	err := collection.FindOne(context.Background(), bson.M{"_id": id}).Decode(&one)
	if err != nil {
		log.Println(err)
	}
	return one
}

//添加天然气用量
func ResultGas(id interface{}, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var one model.NaturalGasUsage
	err := collection.FindOne(context.Background(), bson.M{"_id": id}).Decode(&one)
	if err != nil {
		log.Println(err)
	}
	return one
}

//浸渍2
//浸渍系统运行记录
func ResultDipNote(id interface{}, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var one model.DippingSystemNote
	err := collection.FindOne(context.Background(), bson.M{"_id": id}).Decode(&one)
	if err != nil {
		log.Println(err)
	}
	return one
}

//石墨化1
//用户质量要求
func ResultQua(id interface{}, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var one model.QualityRequired
	err := collection.FindOne(context.Background(), bson.M{"_id": id}).Decode(&one)
	if err != nil {
		log.Println(err)
	}
	return one
}

//装炉报告
func ResultLoad(id interface{}, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var one model.LoadOven
	err := collection.FindOne(context.Background(), bson.M{"_id": id}).Decode(&one)
	if err != nil {
		log.Println(err)
	}
	return one
}

//送电曲线
func ResultEle(id interface{}, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var one model.ElectricityCurve
	err := collection.FindOne(context.Background(), bson.M{"_id": id}).Decode(&one)
	if err != nil {
		log.Println(err)
	}
	return one
}

//石墨化2
//返回基础信息
func ResultBasic(id interface{}, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var one model.BasicInformation
	err := collection.FindOne(context.Background(), bson.M{"_id": id}).Decode(&one)
	if err != nil {
		log.Println(err)
	}
	return one
}

//详细信息
func ResultDetail(id interface{}, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var one model.DetailedInformation
	err := collection.FindOne(context.Background(), bson.M{"_id": id}).Decode(&one)
	if err != nil {
		log.Println(err)
	}
	return one
}

//成型1
//筛分记录
func ResultScr(id interface{}, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var one model.ScreeningRecord
	err := collection.FindOne(context.Background(), bson.M{"_id": id}).Decode(&one)
	if err != nil {
		log.Println(err)
	}
	return one
}

//成型2
//配料记录
func ResultIngredient(id interface{}, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var one model.IngredientRecord
	err := collection.FindOne(context.Background(), bson.M{"_id": id}).Decode(&one)
	if err != nil {
		log.Println(err)
	}
	return one
}

//库管
//原始记录
func ResultInit(id interface{}, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var one model.InitRecord
	err := collection.FindOne(context.Background(), bson.M{"_id": id}).Decode(&one)
	if err != nil {
		log.Println(err)
	}
	return one
}

//质检
//检查日报
func ResultDaily(id interface{}, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var one model.DailyReport
	err := collection.FindOne(context.Background(), bson.M{"_id": id}).Decode(&one)
	if err != nil {
		log.Println(err)
	}
	return one
}

//产品信息
func ResultPro(id interface{}, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var one model.Production
	err := collection.FindOne(context.Background(), bson.M{"_id": id}).Decode(&one)
	if err != nil {
		log.Println(err)
	}
	return one
}

//隧道窑
//测点信息
func ResultLoc(id interface{}, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var one model.LocationInfo
	err := collection.FindOne(context.Background(), bson.M{"_id": id}).Decode(&one)
	if err != nil {
		log.Println(err)
	}
	return one
}

//进车信息
func ResultIncar(id interface{}, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var one model.Incar_Info
	err := collection.FindOne(context.Background(), bson.M{"_id": id}).Decode(&one)
	if err != nil {
		log.Println(err)
	}
	return one
}

//出车
func ResultOutcar(id interface{}, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var one model.Outcar_Info
	err := collection.FindOne(context.Background(), bson.M{"_id": id}).Decode(&one)
	if err != nil {
		log.Println(err)
	}
	return one
}

//交接班
func ResultHan_Suc(id interface{}, col string) interface{} {
	db := database.GetMongoDB()
	collection := db.Collection(col)
	var one model.Handover_Successor
	err := collection.FindOne(context.Background(), bson.M{"_id": id}).Decode(&one)
	if err != nil {
		log.Println(err)
	}
	return one
}
//货物管理 数量表
func ResultAmount(id interface{}, col string) interface{} {
	db := database.GetMongoDB()
	collection:=db.Collection(col)
	var num model.Amount
	err := collection.FindOne(context.Background(),bson.M{"_id":id}).Decode(&num)
	if err !=nil {
		log.Println(err)
	}
	return num
}
func ResultWeight(id interface{},col string) interface{} {
	db := database.GetMongoDB()
	collection:=db.Collection(col)
	var wei model.Weight
	err := collection.FindOne(context.Background(),bson.M{"_id":id}).Decode(&wei)
	if err !=nil {
		log.Println(err)
	}
	return wei
}
